<script lang="ts" setup>
import SuperTable from "@/module/table/superTable.vue";
import {ref} from "vue";
import {ParkingLogSearchBo, ParkingLogVo} from "@/dto/Log/ParkingLog.ts";
import {ParkingLogApi} from "@/api/log/ParkingLogApi.ts";
import {Page} from "@/common/Page.ts";
import {FileVo} from "@/dto/file/File.ts";

const initTable = ref<Array<ParkingLogVo>>([])
const parkingLogApi = ref(new ParkingLogApi())
const parkingLogSearchBo = ref(new ParkingLogSearchBo())
const pageConfig = ref(Page.initPage)

async function initTableData(page: Page) {
    parkingLogSearchBo.value.page = page.page
    parkingLogSearchBo.value.limit = page.pageSize
    let result = await parkingLogApi.value.pageAll(parkingLogSearchBo.value)
    initTable.value = result.data?.content ?? []
    pageConfig.value = new Page(page.page, page.pageSize, <number>result.data?.totalPages, <number>result.data?.totalElements)
}

</script>

<template>
    <super-table
            :data="initTable"
            :column-list="ParkingLogVo.getColumn()"
            :page="pageConfig"
            @init="initTableData"
    >
        <template #column="{row,column}">
            <template v-if="column.prop == 'isMember'">
                <el-tag v-if="row[column.prop]" type="success" effect="dark">
                    会员
                </el-tag>
                <el-tag v-else type="danger" effect="dark">
                    游客
                </el-tag>
            </template>
        </template>
    </super-table>
</template>

<style scoped>

</style>